package com.bestcem.xm.user.service;

import com.alibaba.fastjson.JSONObject;
import com.bestcem.xm.common.core.domain.web.ServiceResult;
import com.bestcem.xm.user.grpc.client.dto.IndustryDTO;
import com.bestcem.xm.user.grpc.client.dto.PackageDTO;
import com.bestcem.xm.user.service.dto.redis.UserRegisterDTO;
import com.bestcem.xm.user.service.dto.user.OrgRegisterDTO;
import com.bestcem.xm.user.service.dto.user.OrganizationDTO;
import com.bestcem.xm.user.service.dto.user.UserDTO;

import java.util.Date;
import java.util.List;

/**
 * 用户公司业务Service
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/3/8 14:35
 */
public interface UserOrgBusinessService {

    /**
     * 预创建注册公司
     *
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/8 14:54
     */
    void createPreOrgForRegister();

    /**
     * 创建免费公司
     *
     * @param organizationDTO
     * @param sampleOrgCode
     * @return ServiceResult<String>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/8 17:57
     */
    ServiceResult<String> createFreeOrg(OrganizationDTO organizationDTO, String sampleOrgCode);

    /**
     * 创建免费系统用户
     *
     * @param userDTO
     * @return ServiceResult<String>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/8 17:58
     */
    ServiceResult<String> createFreeSystemUser(UserDTO userDTO);

    /**
     * copySample
     *
     * @param organizationDTO
     * @param sampleOrgCode
     * @return ServiceResult<Void>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/7/14 16:34
     */
    ServiceResult<Void> copySample(OrganizationDTO organizationDTO, String sampleOrgCode);

    /**
     * 校验公司code
     *
     * @param code
     * @return ServiceResult<String>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/8 18:24
     */
    ServiceResult<String> checkOrgCode(String code);

    /**
     * 注册公司-设置公司和用户
     *
     * @param orgRegisterDTO  注册公司dto
     * @param userRegisterDTO 注册用户dto
     * @param industryDTO     行业
     * @return ServiceResult<UserDTO>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/3/8 22:13
     */
    ServiceResult<JSONObject> registerOrg(OrgRegisterDTO orgRegisterDTO, UserRegisterDTO userRegisterDTO, IndustryDTO industryDTO);

    /**
     * 设置公司套餐信息
     *
     * @param organizationDTO
     * @param freeTrialPackage
     * @param freePackage
     * @param now
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/3/10 19:10
     */
    void setOrgPackageInfo(OrganizationDTO organizationDTO, PackageDTO freeTrialPackage, PackageDTO freePackage, Date now);

    /**
     * 创建公司信息
     *
     * @param dto          公司信息
     * @param password     密码
     * @param source       来源
     * @param sourceRemark 来源描述
     * @param isSuper      是否是管理员
     * @param baseorgCode  基础orgCode
     * @return com.bestcem.xm.util.ServiceResult<java.lang.String>
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2022/05/15 14:07
     */
    ServiceResult<String> createOrganization(OrganizationDTO dto, String password, Integer source, String sourceRemark,
                                             boolean isSuper, String baseorgCode);

    /**
     * 获取行业示例的租户代号
     *
     * @param codesList 已有的公司编码集合
     * @return ServiceResult<List < OrganizationDTO>>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/6/29 16:03
     */
    ServiceResult<List<OrganizationDTO>> listIndustrySampleCodes(List<String> codesList);

    /**
     * 通过公司id校验公司是否到期
     *
     * @param orgId
     * @return ServiceResult<Boolean>
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/7/5 17:29
     */
    ServiceResult<Boolean> checkOrgExpire(String orgId);

    /**
     * 系统商后台，创建租户
     *
     * @param dto
     * @param managerEmail
     * @param managerPhone
     * @return com.bestcem.xm.util.ServiceResult<java.lang.String>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/7/6 11:12
     */
    ServiceResult<String> createOrgFromBackend(OrganizationDTO dto, String managerEmail, String managerPhone);

    /**
     * 预计审核通过，创建租户
     *
     * @param dto
     * @param managerEmail
     * @param managerPhone
     * @return com.bestcem.xm.util.ServiceResult<java.lang.String>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/7/7 16:26
     */
    ServiceResult<String> acceptBooking(OrganizationDTO dto, String managerEmail, String managerPhone);
}
